<template>
  <div class="header-con">
    <div class="header-img">
      <img
        src="../assets/img/logo.png"
        alt=""
        class="img1"
        style="margin-left: 10px"
      />
      <span
        v-if="sidebar"
        class="el-icon-s-unfold"
        @click="TOGGLE_SIDEBAR"
      ></span>
      <span v-else class="el-icon-s-fold" @click="TOGGLE_SIDEBAR"></span>
    </div>
    <div class="header-text">
      <span>{{ username }}({{ type == 1 ? "超级管理员" : "普通管理员" }})</span>
      <img src="../assets/img/gita.gif" alt="" class="img2" />
      <span class="line">|</span>
      <span @click="LogoutAction">退出登录</span>
      <img src="../assets/img/cn.png" alt="" class="img3" />
    </div>
  </div>
</template>

<script>
import { mapMutations, mapGetters, mapActions } from "vuex";

export default {
  name: "MyHeader",
  methods: {
    ...mapMutations(["TOGGLE_SIDEBAR"]),
    ...mapActions(["LogoutAction"]),
  },
  computed: {
    ...mapGetters(["username", "type"]),
    ...mapGetters(["sidebar"]),
  },
};
</script>

<style lang="scss" scoped>
.header-con {
  display: flex;
  justify-content: space-between;
  align-items: center;
  .header-img {
    display: flex;
    align-items: center;
    span {
      margin-left: 10px;
      font-size: 20px;
    }
  }
  .header-text {
    display: flex;
    align-items: center;
    color: #605897;
    span {
      margin-left: 5px;
      margin-right: 5px;
    }
    .line {
      color: #e0dfdf;
    }
  }
  .img1 {
    height: 40px;
  }
  .img2 {
    height: 40px;
  }
  .img3 {
    height: 50px;
  }
}
</style>